import Combine
import SwiftUI

@MainActor
struct MoviesNavigationView: View {
    @Bindable
    private var coordinator: MoviesCoordinator
    
    private let viewModel: MoviesViewModel

    
    init(coordinator: MoviesCoordinator, viewModel: MoviesViewModel) {
        self.coordinator = coordinator
        self.viewModel = viewModel
    }
    
    var body: some View {
        NavigationStack(path: $coordinator.routes) {
            MoviesListView(viewModel: viewModel)
                .navigationTitle("Movies")
                .navigationDestination(for: MoviesCoordinator.Route.self) { route in
                    switch route {
                    case .movieDetail(let route):
                        MovieDetailView(viewMode: route.value)
                    case .personDetail(let route):
                        PersonDetailView(viewMode: route.value)
                    
                    }
                }
        }
    }
}

